﻿@using InfoTech.VinhSon.Bussiness
@model IEnumerable<Category>
<div class="menu1">
    <div id="myslidemenu" class="jqueryslidemenu">
        <ul>
            <li class="menu_padding"><a href="/Trang-chu">TRANG CHỦ</a></li>
            @{
                foreach (Category category in Model.OrderBy(c => c.Priority ?? int.MaxValue).ThenBy(c => c.Name))
                {
                    bool hasChild = category.Categories.Any(c => c.IsShowMenu == true && c.Activated == true && c.Inactive == false);
                <li class="menu_padding"><a @(hasChild ? "" : "href=" + category.GetUrl())>@category.Name</a>
                    @{
                    if (hasChild)
                    {
                        <ul>
                            @{
                        foreach (Category sub_category in category.Categories.Where(c => c.IsShowMenu == true && c.Activated == true && c.Inactive == false)
                                                                  .OrderBy(c => c.Priority ?? int.MaxValue).ThenBy(c => c.Name))
                        {
                                <li><a href="@sub_category.GetUrl()">@sub_category.Name</a>
                                    @{
                            if (sub_category.Categories.Any(c => c.IsShowMenu == true && c.Activated == true && c.Inactive == false))
                            {
                                        <ul>
                                            @{
                                foreach (Category sub_category2 in sub_category.Categories.Where(c => c.IsShowMenu == true && c.Activated == true && c.Inactive == false)
                                                                               .OrderBy(c => c.Priority ?? int.MaxValue).ThenBy(c => c.Name))
                                {
                                                <li><a href="@sub_category2.GetUrl()">@sub_category2.Name</a></li>
                                }
                                            }
                                        </ul>
                            }
                                    }
                                </li>
                        }
                            }
                        </ul>
                    }
                    }
                </li>
                }
            }
        </ul>
        <br style="clear: left" />
    </div>
</div>
